package memberships;

import java.util.ArrayList;

import utils.Point;

/**
 * Represents trapezoidal membership function. Contains four points which build this function.
 * @author adam.taciak
 * @version 1.0
 *
 */
public class Trapezoidal extends MembershipFunction {
	private Point a;
	private Point b;
	private Point c;
	private Point d;
	
	public Trapezoidal() {
		points = new ArrayList<>();
	}
	
	public Trapezoidal(Point a, Point b, Point c, Point d) {
		points = new ArrayList<>();
		points.add(a);
		points.add(b);
		points.add(c);
		points.add(d);
		
		this.a = a;
		this.b = b;
		this.c = c;
		this.d = d;
	}
	
	public void setA(Point a) {
		this.a = a;
		refreshPointsList();
	}
	
	public void setB(Point b) {
		this.b = b;
		refreshPointsList();
	}
	
	public void setC(Point c) {
		this.c = c;
		refreshPointsList();
	}
	
	public void setD(Point d) {
		this.d = d;
		refreshPointsList();
	}
	
	public Point getA() {
		return a;
	}
	
	public Point getB() {
		return b;
	}
	
	public Point getC() {
		return c;
	}
	
	public Point getD() {
		return d;
	}
	
	/**
	 * Refresh points list. Remove current content of list and append points a, b and c.
	 */
	private void refreshPointsList() {
		points.clear();
		points.add(a);
		points.add(b);
		points.add(c);
		points.add(d);
	}
}
